﻿<%@ Page Title="Create User" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Create_User.aspx.cs" Inherits="admin_Create_User" %>

<asp:Content ID="Head" ContentPlaceHolderID="head" runat="Server">
    <link href="../styles/admin.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="top_menu">
        <div id="help_button">
            help
        </div>
                  <div id="logout">
            <asp:LoginStatus ID="LoginStatus1" runat="server" LogoutPageUrl="../Default.aspx"
                OnLoggingOut="LoginStatus1_LoggingOut" />
        </div>
    </div>
    <div id="page_title">
        ADMINISTRATION
    </div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <div id="left_content">
        <div class="menu">
            <ul>
                <li><a href="Home.aspx">Home</a></li>
                <li><a href="#" class="current">Create New User</a></li>
                <li><a href="Mng_Site.aspx">Manage Sites</a></li>
                <li><a href="Mng_Machine.aspx">Manage Machines</a></li>
                <li><a href="Mng_Comp.aspx">Manage Components</a></li>
                <li><a href="Mng_Report.aspx">Manage Reports</a></li>
                <li><a href="Mng_WO.aspx">Manage Work Order</a></li>
                <li><a href="Mng_FaultsRecom.aspx">Manage Faults Recommendation</a></li>
            </ul>
        </div>
    </div>
    <!-- end of left content -->
    <div id="right_content">
        <div class="content_area">
            <h2>
                Create User Account
            </h2>
            <h3>
                <asp:Label ID="clientNameLabel" runat="server" Text="Client Name"></asp:Label>
            </h3>
            <div class="form_box1">
                <asp:FormView ID="FormViewUsers" runat="server" DataKeyNames="user_id" DataSourceID="UsersObjectDataSource"
                    DefaultMode="Insert" OnItemInserted="FormViewUsers_ItemInserted" OnDataBound="FormViewUsers_DataBound"
                    Style="direction: ltr" oniteminserting="FormViewUsers_ItemInserting">
                    <InsertItemTemplate>
                        <asp:TextBox ID="is_adminTextBox" runat="server" Text='<%# Bind("is_admin") %>' Visible="False" />
                        <asp:TextBox ID="client_idTextBox" runat="server" Text='<%# Bind("client_id") %>'
                            Visible="False" />
                        <table>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:RequiredFieldValidator ID="nameRequiredFieldValidator" runat="server" ErrorMessage="Full Name is required"
                                        ControlToValidate="nameTextBox" ValidationGroup="FormViewUsers" CssClass="requiredFieldValidator">
                                    </asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Full Name:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>' AutoCompleteType="None"
                                        CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:RequiredFieldValidator ID="usernameRequiredFieldValidator" runat="server" ErrorMessage="Username is required"
                                        ControlToValidate="usernameTextBox" ValidationGroup="FormViewUsers" CssClass="requiredFieldValidator">
                                    </asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Username:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="usernameTextBox" runat="server" Text='<%# Bind("username") %>' AutoCompleteType="DisplayName"
                                        CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:RegularExpressionValidator ID="PasswordRegularExpressionValidator" runat="server"
                                        ErrorMessage="Minimum password lenght is 5" ControlToValidate="passwordTextBox"
                                        ValidationExpression=".{5}.*" ValidationGroup="FormViewUsers" CssClass="requiredFieldValidator">
                                    </asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Password:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="passwordTextBox" runat="server" Text='<%# Bind("password") %>' TextMode="Password"
                                        CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:CompareValidator ID="passwordCompareValidator" runat="server" ErrorMessage="Password must be the same"
                                        ControlToValidate="confirmPassword" ControlToCompare="passwordTextBox" SetFocusOnError="True"
                                        ValidationGroup="FormViewUsers" CssClass="requiredFieldValidator">
                                    </asp:CompareValidator>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Confirm Password:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="confirmPassword" runat="server" TextMode="Password" CssClass="fields1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td colspan="2">
                                    <asp:RegularExpressionValidator ID="EmailRegularExpressionValidator" runat="server"
                                        ErrorMessage="Email address is not valid" ValidationGroup="FormViewCreateClient"
                                        ControlToValidate="emailTextBox" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                        CssClass="requiredFieldValidator">
                                    </asp:RegularExpressionValidator>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Email:
                                </td>
                                <td colspan="2">
                                    <asp:TextBox ID="emailTextBox" runat="server" Text='<%# Bind("email") %>' CssClass="fields1" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    Role:
                                </td>
                                <td colspan="2">
                                    <asp:DropDownList ID="roleDropDownList" runat="server" Text='<%# Bind("role") %>'
                                        CssClass="dropDownList">
                                        <asp:ListItem Value="Admin">Admin</asp:ListItem>
                                        <asp:ListItem Value="Staff" Selected="True">Staff</asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td class="Li_buttonC">
                                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                                        Text="Insert" ValidationGroup="FormViewUsers" />
                                </td>
                                <td class="Li_buttonC">
                                    <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                        Text="Cancel" OnClick="InsertCancelButton_Click" />
                                </td>
                            </tr>
                        </table>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        user_id:
                        <asp:Label ID="user_idLabel" runat="server" Text='<%# Eval("user_id") %>' />
                        <br />
                        username:
                        <asp:Label ID="usernameLabel" runat="server" Text='<%# Bind("username") %>' />
                        <br />
                        password:
                        <asp:Label ID="passwordLabel" runat="server" Text='<%# Bind("password") %>' />
                        <br />
                        is_admin:
                        <asp:Label ID="is_adminLabel" runat="server" Text='<%# Bind("is_admin") %>' />
                        <br />
                        role:
                        <asp:Label ID="roleLabel" runat="server" Text='<%# Bind("role") %>' />
                        <br />
                        client_id:
                        <asp:Label ID="client_idLabel" runat="server" Text='<%# Bind("client_id") %>' />
                        <br />
                        name:
                        <asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name") %>' />
                        <br />
                        email:
                        <asp:Label ID="emailLabel" runat="server" Text='<%# Bind("email") %>' />
                        <br />
                        <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                            Text="New" />
                    </ItemTemplate>
                </asp:FormView>
                <asp:ObjectDataSource ID="UsersObjectDataSource" runat="server" InsertMethod="Insert"
                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="DataAccess.i2iPortalTableAdapters.UsersTableAdapter">
                    <InsertParameters>
                        <asp:Parameter Name="username" Type="String" />
                        <asp:Parameter Name="password" Type="String" />
                        <asp:Parameter Name="is_admin" Type="String" />
                        <asp:Parameter Name="role" Type="String" />
                        <asp:Parameter Name="client_id" Type="Int32" />
                        <asp:Parameter Name="name" Type="String" />
                        <asp:Parameter Name="email" Type="String" />
                    </InsertParameters>
                </asp:ObjectDataSource>
            </div>
        </div>
    </div>
    <!-- end of right content -->
</asp:Content>
